using System;
using System.Linq;
using System.Collections.Generic;
using DevExpress.CodeRush.StructuralParser;

namespace CR.StyleCop.Naming {

    public class NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetterSearcher : BaseStyleCopIssueSearcher<IFieldElement> {

        public override IEnumerable<StyleCopIssue> FindIssues(IEnumerable<IFieldElement> elements) {
            return elements.Where(f => f.Visibility != MemberVisibility.Private)
                .Where(f => f.IsReadOnly)
                .Where(f => char.IsLower(f.Name[0]))
                .Select(f => new StyleCopIssue {
                    Element = f,
                    IssueDescription = StyleCop.Resource.NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetterSearcherIssueDescription
                });
        }
    }
}